//
//  FLMExchangeViewController.m
//  FLMSuperS
//
//  Created by xiaoyang on 16/9/6.
//  Copyright © 2016年 FaLaoMiaoNetworkTechnologyCo. All rights reserved.
//

#import "FLMExchangeViewController.h"
#import "FLMYMeHeadView.h"
#import "FLMMeSettingCell.h"
#import "MBProgressHUD+MJ.h"

@interface FLMExchangeViewController ()<UITableViewDelegate,UITableViewDataSource,MeHeadViewDelegate>
@property (nonatomic,strong)UITableView    * tableView_show;
@property (nonatomic,strong)NSMutableArray * array_data;
@end

@implementation FLMExchangeViewController

- (UITableView *)tableView_show
{
    if (_tableView_show!=nil) {
        return _tableView_show;
    }
    _tableView_show = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, ScreenW, ScreenH) style:UITableViewStylePlain];
    _tableView_show.delegate = self;
    _tableView_show.dataSource = self;
    _tableView_show.separatorStyle = UITableViewCellSelectionStyleNone;
    return _tableView_show;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor whiteColor];

    [self.navigationController.navigationBar setBackgroundImage:[UIImage imageWithColor:[UIColor whiteColor]] forBarMetrics:UIBarMetricsDefault];
    self.navigationController.navigationBarHidden = YES;
    
    [self.view addSubview:self.tableView_show];
    FLMYMeHeadView *headV =  [[[NSBundle mainBundle] loadNibNamed:@"FLMYMeHeadView" owner:self options:nil] lastObject];
    headV.delegate = self;
    self.tableView_show.tableHeaderView = headV;
    [self.tableView_show registerNib:[UINib nibWithNibName:@"FLMMeSettingCell" bundle:[NSBundle mainBundle]] forCellReuseIdentifier:@"FLMMeSettingCell"];
    
}

- (NSMutableArray *)array_data
{
    if (_array_data != nil) {
        return _array_data;
    }
    _array_data = [[NSMutableArray alloc] init];
    [_array_data addObjectsFromArray: @[@"订单管理",@"账户明细",@"公告",@"兑换商城",@"收货地址",@"邀请好友",@"帮助中心",@"关于超级买",@"退出"]];
    return _array_data;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return  self.array_data.count;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 44;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString * identifier = @"FLMMeSettingCell";
    FLMMeSettingCell * cell = [tableView dequeueReusableCellWithIdentifier:identifier];
    cell.title = self.array_data[indexPath.row];
    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    if (indexPath.row == 8) {
        NSLog(@"退出");
        [[NSUserDefaults standardUserDefaults]  setObject:@"" forKey:@"username"];
        [[NSUserDefaults standardUserDefaults]  setObject:@"" forKey:@"password"];
        [[NSUserDefaults standardUserDefaults] synchronize];
        [MBProgressHUD showSuccess:@"退出成功!"];
    }
}

- (void)headView:(FLMYMeHeadView *)view clicked:(NSInteger)index
{
    NSLog(@"%ld",index);
}



- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
